package com.cwt_taxi_xa.db.bll;

import android.app.Activity;
import android.provider.Settings;
import android.view.Window;
import android.view.WindowManager;
/**
 * 系统业务类
 * @author wlh
 */
public class CarCallSystemBiz {

	public static int SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1;	//为自动调节屏幕亮度
	public static int SCREEN_BRIGHTNESS_MODE_MANUAL=0;	//为手动调节屏幕亮度

	/**
	 * 获得当前屏幕亮度的模式
	 * SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 为自动调节屏幕亮度
	 * SCREEN_BRIGHTNESS_MODE_MANUAL=0  为手动调节屏幕亮度
	 */
	public static int getScreenMode(Activity activity){
		int screenMode=0;
		try{
			screenMode = Settings.System.getInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE);
		}
		catch (Exception localException){
		}
		return screenMode;
	}

	/**
	 * 获得当前屏幕亮度值  0--255
	 */
	public static int getScreenBrightness(Activity activity){
		int screenBrightness=255;
		try{
			screenBrightness = Settings.System.getInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
		}
		catch (Exception localException){

		}
		return screenBrightness;
	}
	/**
	 * 设置当前屏幕亮度的模式
	 * SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 为自动调节屏幕亮度
	 * SCREEN_BRIGHTNESS_MODE_MANUAL=0  为手动调节屏幕亮度
	 */
	public static void setScreenMode(Activity activity, int paramInt){
		try{
			Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, paramInt);
		}catch (Exception localException){
			localException.printStackTrace();
		}
	}
	/**
	 * 设置当前屏幕亮度值  0--255
	 */
	public static void saveScreenBrightness(Activity activity, int paramInt){
		try{
			Settings.System.putInt(activity.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, paramInt);
		}
		catch (Exception localException){
			localException.printStackTrace();
		}
	}
	/**
	 * 保存当前的屏幕亮度值，并使之生效
	 */
	public static void setScreenBrightness(Activity activity, int paramInt){
		Window localWindow = activity.getWindow();
		WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes();
		float f = paramInt / 255.0F;
		localLayoutParams.screenBrightness = f;
		localWindow.setAttributes(localLayoutParams);
	}

	/**
	 * 获取当前手机系统版本号
	 *
	 * @return  系统版本号
	 */
	public static String getSystemVersion() {
		return android.os.Build.VERSION.RELEASE;
	}
}
